package com.ruoyi.project.paea.paeaDsTeller.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.paea.paeaDsTeller.domain.PaeaDsTeller;
import com.ruoyi.project.paea.paeaDsTeller.service.IPaeaDsTellerService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 日柜员Controller
 *
 * @author ruoyi
 * @date 2020-03-27
 */
@Controller
@RequestMapping("/paea/paeaDsTeller")
public class PaeaDsTellerController extends BaseController
{
    private String prefix = "paea/paeaDsTeller";

    @Autowired
    private IPaeaDsTellerService paeaDsTellerService;

    @RequiresPermissions("paea:paeaDsTeller:view")
    @GetMapping()
    public String paeaDsTeller()
    {
        return prefix + "/paeaDsTeller";
    }

    /**
     * 查询日柜员列表
     */
    @RequiresPermissions("paea:paeaDsTeller:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaDsTeller paeaDsTeller)
    {
        startPage();
        List<PaeaDsTeller> list = paeaDsTellerService.list(new QueryWrapper<>(paeaDsTeller));
        return getDataTable(list);
    }

    /**
     * 导出日柜员列表
     */
    @RequiresPermissions("paea:paeaDsTeller:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaDsTeller paeaDsTeller)
    {
        List<PaeaDsTeller> list = paeaDsTellerService.list(new QueryWrapper<>(paeaDsTeller));
        ExcelUtil<PaeaDsTeller> util = new ExcelUtil<PaeaDsTeller>(PaeaDsTeller.class);
        return util.exportExcel(list, "paeaDsTeller");
    }

    /**
     * 新增日柜员
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日柜员
     */
    @RequiresPermissions("paea:paeaDsTeller:add")
    @Log(title = "日柜员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaDsTeller paeaDsTeller)
    {
        return toAjax(paeaDsTellerService.saveOrUpdate(paeaDsTeller));
    }

    /**
     * 修改日柜员
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaDsTeller paeaDsTeller = paeaDsTellerService.getById(id);
        mmap.put("paeaDsTeller", paeaDsTeller);
        return prefix + "/edit";
    }

    /**
     * 修改保存日柜员
     */
    @RequiresPermissions("paea:paeaDsTeller:edit")
    @Log(title = "日柜员", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaDsTeller paeaDsTeller)
    {
        return toAjax(paeaDsTellerService.saveOrUpdate(paeaDsTeller));
    }

    /**
     * 删除日柜员
     */
    @RequiresPermissions("paea:paeaDsTeller:remove")
    @Log(title = "日柜员", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaDsTellerService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
